<script setup>
import OImage from "../setting/Images.vue";
import AlphaColor from "../setting/AlphaColor.vue";
import Editor from "../setting/Editor.vue";
import Slider from "../setting/Slider.vue";
import Color from "../setting/Color.vue";

const props = defineProps({
  config: {
    type: Object,
    required: true,
  },
  name: {
    type: String,
    default: "",
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});

const emits = defineEmits(["update:config", "change"]);

const form = ref({
  $position: { top: 145, left: 41 },
  $positionType: "absolute",
  $size: { width: 306, height: 375 },
  $removeable: false,
  $mode: "background",
  showBgImg: false,
  borderRadius: 10,
  color: "#333333",
  bgColor: "#ffffff",
});

const typeList = [
  { label: "自定义", key: "none" },
  { label: "中奖弹窗", key: "winnerPrize" },
  { label: "未中奖弹窗", key: "thanksPrize" },
];

const detail = computed({
  get: () => {
    return Object.assign({}, form.value, props.config);
  },
  set: (val) => {
    emits("update:config", val);
    emits("change", val);
  },
});

const onChange = (val) => {
  detail.value = detail.value;
};

onMounted(() => {
  nextTick(() => {
    onChange();
  });
});
</script>
<template>
  <el-form :model="detail" :disabled="disabled" label-width="auto">
    <AlphaColor v-model="detail.bgColor" name="背景色" @change="onChange" />
    <Slider
      v-model="detail.borderRadius"
      name="圆角"
      :max="20"
      @change="onChange"
    />
    <OImage
      v-model="detail.backgroundImg"
      v-model:size="detail.$size"
      v-model:show="detail.showBgImg"
      name="背景图片"
      @change="onChange"
    />
    <!-- <OImage
      v-model="detail.closeImg"
      v-model:size="detail.closeImgSize"
      name="关闭按钮"
      @change="onChange"
    /> -->
  </el-form>
</template>
